package com.ruoyi.web.core.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;
import java.nio.file.Paths;

/**
 * 通用配置
 *
 * @author wiserice
 */
@Configuration
public class ProjectWebMvcConfig implements WebMvcConfigurer
{

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {

        /** 新增：/store/** 映射到 resources/public/store/ */
        String storePath = Paths.get("ruoyi-backend/src/main/resources/public/store").toAbsolutePath().toString();
        registry.addResourceHandler("/store/**")
                .addResourceLocations("classpath:/ruoyi-backend/public/store/")
                .addResourceLocations("file:" + storePath + File.separator);

        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");

        // ✅ 新增：映射 /doc.html 页面
        registry.addResourceHandler("/doc.html")
                .addResourceLocations("classpath:/META-INF/resources/");

    }


}

